package day20170427.annotation;

import java.lang.annotation.Annotation;
import org.junit.Test;

public class StudentServiceImplTest {
	/**
	 * 注解测试
	 * @throws Exception
	 */
	@Test
	public void studentServiceImplTest() throws Exception {
		//1.照妖镜拿到对象才能做事
		Class clazz = Class.forName("day20170427.annotation.StudentServiceImpl");
		//2.拿到对象中的注解
		Annotation[] annotations = clazz.getAnnotations();
		System.out.println("总共有" + annotations.length + "个注解");
		//3.进行超级遍历
		for(Annotation annotation : annotations){
			//4.拿到注解调用里面的属性
			Service service = (Service)annotation;
			System.out.println(service.getAge());
			System.out.println(service.getName());
		}
	}
}
